﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfApplication2.ViewModels.Afiliado;
using WpfApplication2.Helpers;
using WpfApplication2.UserControls;
using WpfApplication2.Validation;
using System.Globalization;

namespace WpfApplication2.Views.Afiliado
{
    /// <summary>
    /// Interaction logic for NuevoAfiliado.xaml
    /// </summary>
    public partial class NuevoAfiliado : Page
    {
        public ModalDialog modalDialog { get; set; }
        public Frame ContainerFrame
        {
            get;
            set;
        }


        public NuevoAfiliado(Frame frame, ModalDialog modal)
        {
            InitializeComponent();
            DataContext = new NuevoAfiliadoViewModel(frame, modal);
            ContainerFrame = frame;
            modalDialog = modal;
        }

        private void numerosTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key >= Key.D0 && e.Key <= Key.D9 || e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9 || e.Key == Key.Tab)
                e.Handled = false;
            else
                e.Handled = true;
        }

        

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            NuevoAfiliadoViewModel hola = (NuevoAfiliadoViewModel)DataContext;
            
            hola.SaveAfiliado.Execute(null);
        }

        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            NuevoAfiliadoViewModel context = (NuevoAfiliadoViewModel)DataContext;
            context.LocalidadesCollection = context.WS.GetLocalidadesByProvId(Convert.ToInt32(cmbProvincias.SelectedValue));
        }
    }
}
